package com.rocsun.login;

import com.rocsun.auth.LoginUser;

/**
 * 当前登陆用户持有类
 *
 * @program: rocsun-scali
 * @description: 用来保存当前登陆用户信息，如果请求结束，清理当前用户
 * @author: yx.guo
 * @create: 2025-11-09 11:07
 **/
public class CurrentUserContextHolder {

    private static final ThreadLocal<LoginUser> CURRENT_USER = new ThreadLocal<>();

    public static void setCurrentUser(LoginUser user) {
        CURRENT_USER.set(user);
    }

    public static LoginUser getCurrentUser() {
        return CURRENT_USER.get();
    }

    public static void clearCurrentUser() {
        CURRENT_USER.remove();
    }

}
